/*
 * @lc app=leetcode.cn id=530 lang=javascript
 *
 * [530] 二叉搜索树的最小绝对差
 */

const { func } = require("joi");

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var getMinimumDifference = function(root) {
    let res=[]
    let dfs=function(node){
        if(!node){return }
        dfs(node.left)
        res.push(node.val)
        dfs(node.right)
    }
    dfs(root)
    let min=res[1]-res[0]
    for(let i=1;i<res.length-1;i++){
        min=min<(res[i+1]-res[i])?min:(res[i+1]-res[i])
    }
    return min
};
// @lc code=end

